package com.uphone.magicleafteacher.pro.activity;

import android.graphics.Color;
import android.view.View;

import com.radish.baselibrary.Intent.IntentData;
import com.radish.baselibrary.Intent.IntentUtils;
import com.uphone.magicleafteacher.MyApp;
import com.uphone.magicleafteacher.base.BaseGActivity;
import com.uphone.magicleafteacher.base.BaseListActivity;
import com.uphone.magicleafteacher.http.ApiService;
import com.uphone.magicleafteacher.pro.adapter.StudentClassAdapter;
import com.uphone.magicleafteacher.util.CommonUtil;
import com.uphone.magicleafteacher.util.GsonUtils;
import com.uphone.magicleafteacher.vo.StudentClassBean;
import com.uphone.magicleafteacher.vo.StudentRankBean;

import java.util.List;

import io.reactivex.Observable;
import okhttp3.ResponseBody;

public class StudentClassActivity extends BaseListActivity<StudentClassBean.ClassListBean, StudentClassAdapter> {

    @IntentData
    private int gradeId;
    @IntentData
    private int selectId;

    @Override
    protected Observable<ResponseBody> loadData(ApiService apiService) {
        return MyApp.apiService(ApiService.class)
                .getClassId(gradeId + "");
    }

    @Override
    protected List<StudentClassBean.ClassListBean> getDataList(String json) {
        StudentClassBean bean = GsonUtils.getGson().fromJson(json, StudentClassBean.class);
        if (bean != null)
            return bean.getClassList();

        return null;
    }

    @Override
    protected void itemClick(StudentClassAdapter adapter, View view, int position) {
        IntentUtils.getInstance().with()
                .putInt("classSelectBackId", mAdapter.getItem(position).getClassId())//多选
                .putString("classSelectBackName", mAdapter.getItem(position).getClassName())
                .setResultAndFinish(this, 101);

    }

    @Override
    protected StudentClassAdapter initAdapter() {
        return new StudentClassAdapter(selectId);
    }

    @Override
    protected void initBundle() {
        isDividerLine = false;

    }

    @Override
    protected void initTitle() {
        ll.setBackgroundColor(Color.WHITE);
        initTitle("学生班级");
    }
}
